package com.lfy.kcat.user.controller;

import com.lfy.kcat.user.business.VerifyCodeBizService;
import com.lfy.kcat.user.consts.BizConst;
import com.lfy.kcat.user.vo.SendCodeReqVo;
import com.lfy.kcat.user.vo.SendCodeRespVo;
import org.dromara.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 验证码
 * @author leifengyang
 * @version 1.0
 * @date 2025/9/16 10:30
 * @description:
 */

@RequestMapping("/api")
@RestController
public class VerifyCodeController {

    @Autowired
    private VerifyCodeBizService verifyCodeBizService;

    /**
     * 发送验证码
     * @return
     */
    @PostMapping("/send-code")
    public R sendCode(@RequestBody SendCodeReqVo sendCodeReqVo){
        //TODO 发送验证码
        verifyCodeBizService.sendCode(sendCodeReqVo.getPhone());

        SendCodeRespVo respVo = new SendCodeRespVo();
        respVo.setPhone(sendCodeReqVo.getPhone());
        respVo.setExpires(BizConst.DEFAULT_CODE_EXPIRES);
        return R.ok("验证码发送成功",respVo);
    }
}
